package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.DateUtil;
import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;

@Setter
@Getter
public class TravelCommend extends BaseDomain {

    public static final int TYPE_WEEK = 1;//周推荐
    public static final int TYPE_MONTH = 2;//月推荐
    public static final int TYPE_STRATEGY = 3;//攻略推荐

    private Travel travel;//关联的游记

    private String title;//推荐的标题

    private String subTitle;//推荐的副标题

    private String coverUrl;//封面
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date schedule;//推荐的时间

    private Integer type;//推荐的类型

    public String getJsonString() {
        HashMap<Object, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("travelId", travel.id);
        map.put("title", title);
        map.put("subTitle", subTitle);
        map.put("coverUrl", coverUrl);
        map.put("schedule", DateUtil.formatDate(schedule));
        map.put("type", type);
        return JSONUtil.toJSONString(map);

    }

    public String getTypeName() {
        if (type != null) {
            if (type == TYPE_WEEK) {
                return "周推荐";
            } else if (type == TYPE_MONTH) {
                return "月推荐";
            }
            return "攻略推荐";
        }else{
            return "";
        }
    }

}